<template>
  <view class="tab-bar">
    <view v-for="(tab, index) in tabs" :key="index" @click="switchTab(tab)">
      <image :src="currentTab === tab.pagePath ? tab.selectedIconPath : tab.iconPath" mode="aspectFit"></image>
      <text :class="currentTab === tab.pagePath ? 'active' : ''">{{ tab.text }}</text>
    </view>
  </view>
</template>

<script>
import global from '@/global.js'

export default {
  props: {
     currentTab: {
       type: String,
       required: true
     }
   },
  computed: {
    tabs() {
      return [
        {
          pagePath: '/pages/index/index',
          iconPath: '/static/home.png',
          selectedIconPath: '/static/homeHL.png',
          text: '首页'
        },
        {
          pagePath: '/pages/exhibitionList/exhibitionManager',
          iconPath: '/static/yz.png',
          selectedIconPath: '/static/yzHL.png',
          text: '展览'
        },
		{
		  pagePath: '/pages/orderList/myCart',
		  iconPath: '/static/cart.png',
		  selectedIconPath: '/static/cart_sel.png',
		  text: '购物车'
		},
        {
		  pagePath: '/pages/myMain/myMain',
          iconPath: '/static/user.png',
          selectedIconPath: '/static/userHL.png',
          text: '我的'
        }
      ];
    }
  },
  methods: {
    switchTab(tab) {
      uni.reLaunch({
        url: tab.pagePath
      });
    }
  }
};
</script>


<style>
.tab-bar {
  justify-content: space-around;
  align-items: center;
  height: 120rpx;
  background-color: #f7f7f7;
  border-top: 1px solid #e6e6e6;
  position: fixed;
  bottom: 0;
  z-index: 999;
  width: 100%;
  display: flex;
  justify-content: space-around;
  padding-bottom: 40upx;
}

.tab-bar view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tab-bar image {
  width: 25px;
  height: 25px;
}

.tab-bar text {
  font-size: 12px;
  margin-top: 5px;
}

.tab-bar text.active {
  font-weight: bold;
}
</style>

